var dailyEvents=[];
var oneOffEvents=[];
var monthlyEvents=[];
var yearlyEvents=[];
var rings=[];

function loadEvents() 
{
    //empty all array first
	
	dailyEvents=[];
	oneOffEvents=[];
	monthlyEvents=[];
	yearlyEvents=[];
	
	//get all cookies we want
    var cookies={};
	cookies=getCookies();
	var oneOffData=cookies["oneOff"];
    var dailyData=cookies["daily"];  
	var monthlyData=cookies["monthly"];  
	var yearlyData=cookies["yearly"];
    if (oneOffData!=undefined)
    {
	    var line=oneOffData.split("$");
		for(var i=0; i<line.length-1; i++)
		{
		    oneOffEvents[i]=[];
			
			var att=line[i].split("|");
			for (var j=0; j<att.length; j++)
			{
			    oneOffEvents[i][j]=att[j];
			}
		}
    }  
    if (dailyData!=undefined)
    {
	    var line=dailyData.split("$");
		for(var i=0; i<line.length-1; i++)
		{
		    dailyEvents[i]=[];
			
			var att=line[i].split("|");
			for (var j=0; j<att.length; j++)
			{
			    dailyEvents[i][j]=att[j];
			}
		}
    } 
    if (monthlyData!=undefined)
    {
	    var line=monthlyData.split("$");
		for(var i=0; i<line.length-1; i++)
		{
		    monthlyEvents[i]=[];
			
			var att=line[i].split("|");
			for (var j=0; j<att.length; j++)
			{
			    monthlyEvents[i][j]=att[j];
			}
		}
    } 
    if (yearlyData!=undefined)
    {
	    var line=yearlyData.split("$");
		for(var i=0; i<line.length-1; i++)
		{
		    yearlyEvents[i]=[];
			
			var att=line[i].split("|");
			for (var j=0; j<att.length; j++)
			{
			    yearlyEvents[i][j]=att[j];
			}
		}
    } 	
}


function showAll()
{
    for(var i=0; i<yearlyEvents.length; i++)
	{
	    for(var j=0; j<yearlyEvents[i].length; j++)
		{
		    alert(yearlyEvents[i][j]);
		}
	}
}


function buildClock() 
{
    var cookies={};
	cookies=getCookies();
	var drawRings=[];
	var ringsData=cookies["rings"];
	//set rings for first time user
	if(ringsData==undefined)
	{
	    defaultRings();
	}
	else
	{
	    var line=ringsData.split("$");
	    for(var i=0; i<line.length-1; i++)
	    {
		    rings[i]=[];
	        var att=line[i].split("|");
		    for (var j=0; j<att.length; j++)
		    {
			    rings[i][j]=att[j];
		    }
		    drawRings[i]=new Ring(rings[i][0], parseInt(rings[i][1]), rings[i][2], rings[i][3],rings[i][4], 
		            parseInt(rings[i][5]), rings[i][6], 'myClock');
		    drawRings[i].drawRing();
		    drawRings[i].addMarker();
	    }
	    if(drawRings.length>0)
	    {
	        drawRings[drawRings.length-1].drawHand();
	    }
	    //moon phase will always be shown, can not be turned off
	    var moon= new Ring('moon', 0, '#E0FFFF', "#2B60DE", "#00FF00" ,0,"15px deco", 'myClock' );
	    moon.drawMoonPhase();

	}
    /*
    //sec  
    var clock= new Ring('month', 250, '#E0FFFF', "#2B60DE", "#00FF00" ,12,"15px deco", 'myClock' );
    clock.drawRing();
    clock.addMarker();

	//min
    var clock2= new Ring('date', 208.35, '#E6A9EC', "#2B60DE", "#B93B8F", 30,"15px algerian", 'myClock' );
    clock2.drawRing();
    clock2.addMarker();
    //clock2.addPointer();

	//hr
    var clock3= new Ring('hrs', 166.68, '#57E964', "#2B60DE", "#FF0000", 24, "11px Wide Latin",'myClock' );
    clock3.drawRing();
    clock3.addMarker();
    //clock3.addPointer();
	
	//week
	var clock4= new Ring('mins', 125, '#ADA96E', "#2B60DE", "#FF0000", 60, "10px deco",'myClock' );
    clock4.drawRing();
    clock4.addMarker();
    //clock4.addPointer();
	
	//get the total days of this month
	//var d=daysInMonth();
	var clock5= new Ring('secs', 90, '#C48793', "#2B60DE", "#FF0000", 60, "8px deco",'myClock' );
    clock5.drawRing();
    clock5.addMarker();
    //clock5.addPointer();
	
	var clock6= new Ring('week', 60, '#FFE87C', "#2B60DE", "#FF0000", 7, "12px algerian",'myClock' );
    clock6.drawRing();
    clock6.addMarker();
	clock6.drawHand();
	*/
}